class Solution(object):
    def findDuplicate(self, nums):
        """
        :type nums: List[int]
        :rtype: int
        """
        num = nums[0]
        while True:
            if nums[num] == num:
                return num
            else:
                tmp = nums[num]
                nums[num] = num
                num = tmp
